layui.use(['form', 'layer', 'table', 'laytpl','echarts','element'], function () {
	var layer = top.layui.layer,
		$ = layui.jquery,
		element = layui.element;
		echarts=layui.echarts;

	window.active = {}

	async function getstatistics(){
		let res=await ajaxAsyncNoTip('statistics',{},'GET')
			//初始化图片
			var all = {},
				today = {},
				dial = {},
				lottert={}
			all = res.all[0]
			today =res.today[0]
			dial=res.dial[0]
			lottert=res.lottert[0]
			// 卡片数据
			var strtop =
					`<div class="layui-card layui-card-0" >
					<div class="layui-card-header" style="color: #fff;">
						<h5>注册用户</h5>
						<span>实时</span>
					</div>
					<div class="layui-card-body">
						<div class="col-md-6"> 
							<h1 class="no-margins">${all.userCountAll==null||all.userCountAll==''?0:all.userCountAll}</h1>
							<div class="font-bold">总注册用户</div>
						</div>
						<div class="col-md-6">
							<h1>${today.userCountAll==null||today.userCountAll==''?0:today.userCountAll}</h1>
							<div>当日注册用户</div>
						</div>
					</div>
					</div>
					<div class="layui-card layui-card-1">
						<div class="layui-card-header" style="color: #fff;">
							<h5>销售额</h5>
							<span>实时</span>
						</div>
						<div class="layui-card-body">
							<div class="col-md-6"> 
								<h1 class="no-margins">${all.saleAll==null||all.saleAll==''?0:all.saleAll}</h1>
								<div class="font-bold">总销售额</div>
							</div>
							<div class="col-md-6">
								<h1>${today.saleAll==null||today.saleAll==''?0:today.saleAll}</h1>
								<div>当日销售额</div>
							</div>
						</div>
					</div>
					<div class="layui-card layui-card-6 " >
					<div class="layui-card-header" style="color: #fff;">
						<h5>成交人数</h5>
						<span>实时</span>
					</div>
					<div class="layui-card-body">
						<div class="col-md-6"> 
							<h1 class="no-margins">${all.dealUserAll==null||all.dealUserAll==''?0:all.dealUserAll}</h1>
							<div class="font-bold">总成交人数</div>
						</div>
						<div class="col-md-6">
							<h1>${today.dealUserAll==null||today.dealUserAll==''?0:today.dealUserAll}</h1>
							<div>当日成交人数</div>
						</div>
					</div>
				</div>
					<div class="layui-card layui-card-3" >
						<div class="layui-card-header" style="color: #fff;">
							<h5>盈利额</h5>
							<span>实时</span>
						</div>
						<div class="layui-card-body">
							<div class="col-md-6"> 
								<h1 class="no-margins">${all.profitAll==null||all.profitAll==''?0:all.profitAll}</h1>
								<div class="font-bold">总盈利额</div>
							</div>
							<div class="col-md-6">
								<h1>${today.profitAll==null||today.profitAll==''?0:today.profitAll}</h1>
								<div>当日盈利额</div>
							</div>
						</div>
					</div>
					`
			$('#card-top').html(strtop);
			
			var strmiddle =
					`<div class="layui-card card-mid" style="background: -webkit-gradient(linear,left bottom,left top,color-stop(0,#18bc9c),color-stop(1,#1cdcb6)) !important;">
					<div class="layui-card-header" style="color: #fff;">
						<h5>利润率</h5>
						<span>实时</span>
					</div>
					<div class="layui-card-body">
						<div class="col-md-6"> 
							<h1 class="no-margins">${all.profitLvAll==null||all.profitLvAll==''?0:all.profitLvAll}</h1>
							<div class="font-bold">总利润率</div>
						</div>
						<div class="col-md-6">
							<h1>${today.profitLvAll==null||today.profitLvAll==''?0:today.profitLvAll}</h1>
							<div>当日利润率</div>
						</div>
					</div>
				</div> 
				<div class="layui-card card-mid" style="background: -webkit-gradient(linear,left bottom,left top,color-stop(0,#605ca8),color-stop(1,#9491c4)) !important; ">
					<div class="layui-card-header" style="color: #fff;">
						<h5>统计现金兑换积分比例</h5>
						<span>实时</span>
					</div>
					<div class="layui-card-body">
						<div class="col-md-6"> 
							<h1 class="no-margins">${all.exchangeScoreRatio==null||all.exchangeScoreRatio==''?0:all.exchangeScoreRatio}</h1>
							<div class="font-bold">总比例</div>
						</div>
						<div class="col-md-6">
							<h1>${today.exchangeScoreRatio==null||today.exchangeScoreRatio==''?0:today.exchangeScoreRatio}</h1>
							<div>当日比例</div>
						</div>
					</div>
				</div>
				<div class="layui-card layui-card-4 card-mid" >
					<div class="layui-card-header" style="color: #fff;">
						<h5>出价次数</h5>
						<span>实时</span>
					</div>
					<div class="layui-card-body">
						<div class="col-md-6"> 
							<h1 class="no-margins">${all.offerAll==null||all.offerAll==''?0:all.offerAll}</h1>
							<div class="font-bold">总出价次数</div>
						</div>
						<div class="col-md-6">
							<h1>${today.offerAll==null||today.offerAll==''?0:today.offerAll}</h1>
							<div>当日出价次数</div>
						</div>
					</div>
				</div>
				<div class="layui-card layui-card-5 card-mid">
					<div class="layui-card-header" style="color: #fff;">
						<h5>商品点击数</h5>
						<span>实时</span>
					</div>
					<div class="layui-card-body">
						<div class="col-md-6"> 
							<h1 class="no-margins">${all.goodsViewAll==null||all.goodsViewAll==''?0:all.goodsViewAll}</h1>
							<div class="font-bold">总商品点击数</div>
						</div>
						<div class="col-md-6">
							<h1>${today.goodsViewAll==null||today.goodsViewAll==''?0:today.goodsViewAll}</h1>
							<div>当日商品点击数</div>
						</div>
					</div>
				</div>
				
				<div class="layui-card layui-card-7 card-mid" >
					<div class="layui-card-header" style="color: #fff;">
						<h5>成交商品数</h5>
						<span>实时</span>
					</div>
					<div class="layui-card-body card">
						<div class="col-md-6"> 
							<h1 class="no-margins">${all.dealGoodsAll==null||all.dealGoodsAll==''?0:all.dealGoodsAll}</h1>
							<div class="font-bold">总成交商品数</div>
						</div>
						<div class="col-md-6">
							<h1>${today.dealGoodsAll==null||today.dealGoodsAll==''?0:today.dealGoodsAll}</h1>
							<div>当日成交商品数</div>
						</div>
					</div>
				</div>
					`
			$('#card-middle').html(strmiddle);

		// 九宫格参与人数
		var turntable = echarts.init(document.getElementById('turntable'));
		var turntableNum = echarts.init(document.getElementById('turntableNum'));

		if(dial.winCount==null||dial.winCount==''){
			dial.winCount=0
		}
		if(dial.todayJoinCount==null||dial.todayJoinCount==''){
			dial.todayJoinCount=0
		}

		var seriesdata=[]
		seriesdata=[dial.winCount,dial.todayJoinCount]
		optionturntablenum = {
			title: {
				text: '九宫格参与人数',
			},
			tooltip: {
				trigger: 'axis',
				axisPointer: {            // 坐标轴指示器，坐标轴触发有效
					type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
				}
			},
			grid: {
				left:40,
				containLabel: true
			},
			color:'#4876FF',
			yAxis: [
				{
					type: 'category',
					data:  [ '中奖参与人数', '当日参与人数'],
					axisTick: {
						alignWithLabel: true
					}
				}
			],
			xAxis: [
				{
					type: 'value'
				}
			],
			series: [
				{
					name: '数据统计',
					type: 'bar',
					barWidth: 40,
					data: seriesdata
				}
			]
		};
		turntableNum.setOption(optionturntablenum);

		// 九宫格交易额
		if(dial.scoreAll==null||dial.scoreAll==''){
			dial.scoreAll=0
		}
		if(dial.scoreToday==null||dial.scoreToday==''){
			dial.scoreToday=0
		}
		var seriedata=[]
		seriedata=[dial.scoreAll,dial.scoreToday]
		optionTurntable = {
			title: {
				text: '九宫格抽奖交易额',
			},
			tooltip: {
				trigger: 'axis',
				axisPointer: {            // 坐标轴指示器，坐标轴触发有效
					type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
				}
			},
			grid: {
				left:60,
				containLabel: true
			},
			xAxis: [
				{
					type: 'category',
					data: [ '总交易额', '当日交易额'],
					axisTick: {
						alignWithLabel: true
					}
				}
			],
			yAxis: [
				{
					type: 'value'
				}
			],
			series: [
				{
					name: '数据统计',
					type: 'bar',
					barWidth: 40,
					data: seriedata
				}
			]
		};
		// 使用刚指定的配置项和数据显示图表。
		turntable.setOption(optionTurntable);	


		// 定期交易额
		var statistics = echarts.init(document.getElementById('statistics'));
		var statisticsnum = echarts.init(document.getElementById('statisticsNum'));

		if(lottert.scoreAll==null||lottert.scoreAll==''){
			lottert.scoreAll=0
		}
		if(lottert.scoreToday==null||lottert.scoreToday==''){
			lottert.scoreToday=0
		}
		var serieslottertdata=[]
		serieslottertdata=[lottert.scoreAll,lottert.scoreToday]	
		optionStatistics = {
			title: {
				text: '定期抽奖交易额',
			},
			tooltip: {
				trigger: 'axis',
				axisPointer: {            // 坐标轴指示器，坐标轴触发有效
					type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
				}
			},
			grid: {
				left:60,
				containLabel: true
			},
			xAxis: [
				{
					type: 'category',
					data: [ '总交易额', '当日交易额'],
					axisTick: {
						alignWithLabel: true
					}
				}
			],
			yAxis: [
				{
					type: 'value'
				}
			],
			series: [
				{
					name: '数据统计',
					type: 'bar',
					barWidth: 40,
					data: serieslottertdata
				}
			]
		};
		statistics.setOption(optionStatistics);	

		// 定期人数
		if(lottert.winCount==null||lottert.winCount==''){
			lottert.winCount=0
		}
		if(lottert.todayJoinCount==null||lottert.todayJoinCount==''){
			lottert.todayJoinCount=0
		}
		var seriescountdata=[]
		seriescountdata=[lottert.winCount,lottert.todayJoinCount]
		optionStatisticsnum = {
			title: {
				text: '定期抽奖参与人数',
			},
			tooltip: {
				trigger: 'axis',
				axisPointer: {            // 坐标轴指示器，坐标轴触发有效
					type: 'shadow'        // 默认为直线，可选为：'line' | 'shadow'
				}
			},
			grid: {
				left:40,
				containLabel: true
			},
			color:'#4876FF',
			yAxis: [
				{
					type: 'category',
					data:  [ '中奖参与人数', '当日参与人数'],
					axisTick: {
						alignWithLabel: true
					}
				}
			],
			xAxis: [
				{
					type: 'value'
				}
			],
			series: [
				{
					name: '数据统计',
					type: 'bar',
					barWidth: 40,
					data: seriescountdata
				}
			]
		};
		// 使用刚指定的配置项和数据显示图表。
		statisticsnum.setOption(optionStatisticsnum);	
		}
	getstatistics()

})